import { Alert, Tabs, TabItem } from '@aws-amplify/ui-react'; import AppDirectoryAlert from '@/components/AppDirectoryAlert'; import { Example, ExampleCode } from '@/components/Example'; import { BasicShoppingCard, AdvancedShoppingCard } from '../shared'; import { InstallScripts, TerminalCommand } from '@/components/InstallScripts.tsx'; ## Tutorial In this brief tutorial, we're going to build a basic shopping card component using [Next.js](https://nextjs.org/docs) and Amplify UI. Then, we'll elaborate on our shopping card to play with the possibilities of using Amplify UI. ### App Router ### Setup and Installation First, execute the command below in your terminal. When prompted for the name of your project, enter `amplify-ui-demo`. Then, install the Amplify UI React package: ### Basic Demo Open up the project in your IDE and replace the contents of the `pages/index.js` with the code below: ```tsx file=./examples/BasicExampleCode.tsx ``` Next.js 13.4+ introduced [app directory](https://nextjs.org/docs/app/building-your-application/routing#the-app-directory) with the usage of [Server Components](https://nextjs.org/docs/getting-started/react-essentials#server-components). In this guide we placed `"use client"` at the top of `page.jsx` to mark it as a Client Component. Open up the project in your IDE and replace the contents of the `app/page.jsx` with the code below: ```tsx file=./examples/UseClientBasicExampleCode.tsx ``` When you start the app (`npm run dev` or `yarn dev`), you should see a basic shopping card component. ### Advanced Demo If you’d like to play around with a more comprehensive demo of the Amplify UI library, create a separate file under the `pages` folder named `paintings.js`, and copy/paste this code into it: ```tsx file=./examples/paintings.ts ``` Then, replace the contents of `pages/index.js` with the code below, restart the app, and experience all the beautiful components in action! ```tsx file=./examples/AdvancedExampleCode.tsx ``` Next.js 13.4+ introduced [app directory](https://nextjs.org/docs/app/building-your-application/routing#the-app-directory) with the usage of [Server Components](https://nextjs.org/docs/getting-started/react-essentials#server-components). In this guide we placed `"use client"` at the top of `page.jsx` to mark it as a Client Component. If you’d like to play around with a more comprehensive demo of the Amplify UI library, create a separate file under the `app` folder named `paintings.js`, and copy/paste this code into it: ```tsx file=./examples/paintings.ts ``` Then, replace the contents of `app/page.jsx` with the code below, restart the app, and experience all the beautiful components in action! ```tsx file=./examples/UseClientAdvancedExampleCode.tsx ```